<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>今日提交</title>
    <style>
        html {
            background: linear-gradient(180deg, #edf7fe 0%, white 95%, white 100%);
            min-height: 100%;
        }
        #container {
            max-width: 40vw;
            margin: 0 auto;
            letter-spacing: 1.2px;
            color: rgb(10, 31, 64);
            text-align: center;
            min-height: 90%;
            flex-direction: column;
            justify-content: center;
            display: flex;
            font-family: Arial, sans-serif;
        }
        pre {
            font-size: 18px;
            font-family: math;
            text-align: left;
            white-space: pre-wrap;
        }
        button {
            margin-top: 10px;
        }
        input {
            height: 30px;
            font-size: 16px;
        }
        @media screen and (max-width: 992px){
            #container {
                max-width: 90vw;
            }
        }
    </style>
    <script type="text/javascript">
        async function queryList() {
            let selectedDate = document.getElementById("datePicker").value;
            let data = await getList(selectedDate);
            displayList(data);
        }
        function getList(date) {
            return new Promise((res, rej) => {
                let xhttp = new XMLHttpRequest();
                xhttp.open("POST", "/getText", true);
                xhttp.onreadystatechange = function () {
                    if (this.readyState == 4 && this.status == 200) {
                        res(this.response)
                    }
                };
                xhttp.send(JSON.stringify({date}));
            })
        }
        function displayList(data) {
            let pre = document.getElementById("pre")
            if(!pre){
                pre = document.createElement('pre')
                pre.id = 'pre'
                document.getElementById('container').appendChild(pre)
            }
            pre.innerHTML = data
        }
        window.onload = function(){
            const today = new Date().toISOString().substr(0, 10);
            queryList()
        }
    </script>
</head>

<body>
    <div id="container">
        <input type="date" id="datePicker" oninput="queryList()"/>
    </div>
</body>

</html>